1. Field
Embodiments of the invention relate to managing and coordinating savepoint functionality in a distributed database system.
2. Description of the Related Art
A DataBase Management System (DBMS) may use a Structured Query Language (SQL) interface. The SQL interface has evolved into a standard language for RDBMS software and has been adopted as such by both the American National Standards Institute (ANSI) and the International Standards Organization (ISO). A DBMS stores data in and retrieves data from one or more databases. Each database may be organized into tables that consist of rows and columns of data. The rows may be called tuples or records or rows. A database typically has many tables, and each table typically has multiple records and multiple columns.
Statement savepoint may be described as an internal database protection mechanism to protect statement level atomicity. With statement level atomicity, the effect of a database update produced during a statement execution is either all in or none at the end of the statement execution. If the DBMS encounters an error during the execution of a SQL statement that modifies database objects, the statement savepoint may safely and cleanly undo all the operations associated with this SQL statement so that at the end of the statement execution, the database state is restored to the original state prior to the statement execution. Statement savepoint may be described as an implicit under the cover operation.
In addition to statement savepoint, there is an application savepoint. An application savepoint may be set within an application, and, later, the application savepoint may either be released or rolled back. Releasing an application savepoint ends the savepoint, and there is no impact to the database update work performed. Rollback of an application savepoint, on the other hand, undoes all the database update work that has been performed since the application savepoint was set. There may be any number of savepoints within a single transaction. A transaction may be described as a sequence of database operations that are treated as a unit of work with “ACID” properties (i.e., a transaction is Atomic, produces Consistent results, is Isolated and is Durable). Application savepoint provides control over the work performed by a subset of SQL statements in a transaction. Application savepoint may be described as an explicit request issued by the application. Application savepoints may be nested.
A federated system may be described as consisting of a federated server (e.g., a DB2® instance that operates as a federated server (DB2 is a trademark of International Business Machines Corporation in the United States, other countries, or both)), a database that acts as a federated database, one or more heterogeneous or homogeneous data sources, and clients that access the federated database and data sources. A federated server may be described as providing the client with access to the heterogeneous or homogeneous data sources as if they resided in a single site. A federated database may be described as a database on the federated server instance containing metadata information about data stored on the local database as well as data stored on the data sources. In a federated system, data residing in local or remote data sources may be accessed in a single SQL statement as if data resides in a single site. Under the cover, one SQL statement may be broken into a local portion and one or more remote portions. The local portion of the SQL statement accesses the local database, while each remote portion of the SQL statement accesses a remote data source. Also each remote portion may be translated to a SQL statement that is executable in the remote data source (e.g., the remote portion is written in a dialogue understood by the remote data source).
A federated statement savepoint is used to protect statement level atomicity in a federated system. A federated server administers federated statement savepoint under the cover such that the federated server may safely and cleanly undo all the remote update operations on behalf of a SQL statement in the event of error. The federated statement savepoint may be described as having the following characteristics: 1) the federated statement savepoint is a statement savepoint on a federated server side and an application savepoint on a data source side; 2) the scope is one or more remote SQL statements bundled to provide savepoint functionality for one SQL statement; and 3) the federated statement savepoint is not nested (i.e., there is at most one federated statement savepoint at any time within a distributed transaction).
A federated application savepoint is used to provide control over the work performed by one or more SQL statements against a remote data source under the scope of application savepoint. The federated application savepoint may be described as having the following characteristics: 1) the federated application savepoint is an application savepoint on a federated server side and one or more application savepoints on a data source side; 2) the scope is one or more remote SQL statements bundled to provide savepoint functionality for one application savepoint; and 3) the federated application savepoint may be nested (i.e., there may be multiple application savepoints active at any time within a distributed transaction).
The following Example (1) is a usage example of a federated statement savepoint: